﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.ComponentModel.DataAnnotations;

namespace BlackBird.Models
{
	public class PlanViewDM
	{
		public string ParentId { get; set; }

		public PlanViewItemDM NewPlanView { get; set; }

		/// <summary>
		/// 项目计划状态：待审核，归档。在界面提供提交项目计划，待审核通过后计划
		/// 转为归档状态。
		/// 待审核状态，提交人员可以对项目计划部分进行修改编辑。
		/// 进入归档状态后，只能进行浏览
		/// </summary>
		public SupportTypeStatus PlanStatus { get; set; } 

		public Dictionary<string, List<PlanViewItemDM> > DateToItems { get; set; }
	}

	public class PlanViewItemDM
	{
		public string ParentId { get; set; }

		public string Id { get; set; }

		public string Name { get; set; }

		public SupportTypes type { get; set; }

		public SupportTypeStatus Status { get; set; }

		public List<SelectListItem> DropDownType { get; set; }


		[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:yyyy-MM-dd}")]
		public DateTime FinishTime { get; set; }

		public String FinishTimeString { get; set; }

		/// <summary>
		/// 对收入和支出就是钱了，对事件，没什么意义
		/// </summary>
		public float Count { get; set; }

		[DataType(DataType.MultilineText)]
		public string Comment { get; set; }

		/// <summary>
		/// Convert from PlanViewItemDm to IncomeAndExpendInputDM
		/// In DataBase, we just have Event table that is used to
		/// Save Income, expend, event item.
		/// If the status is plan, then means this object just a plan
		/// item, that cann't be updated late.
		/// </summary>
		/// <returns></returns>
		public 	IncomeAndExpendInputDM GetIncomdeAndExpendObject()
		{
			IncomeAndExpendInputDM dm = new IncomeAndExpendInputDM()
				{
					ParentId = this.ParentId,
					Name = this.Name,
					Count = this.Count,
					Description = this.Comment,
					Date = this.FinishTime,
					Status = this.Status,
					type = this.type
				};

			return dm;
		}
	}
}